package Exercise2;
//定义数组存储3个手机对象
//商品的属性:品牌,价格，颜色
//计算出三部手机的平均价格
public class PhoneTest {
    public static void main(String[] args) {
        Phone[] arr = new Phone[3];
        Phone p1 = new Phone("小米",2000,"黑色");
        Phone p2 = new Phone("vivo",4000,"白色");
        Phone p3 = new Phone("华为",6000,"黑色");

        arr[0] = p1;
        arr[1] = p2;
        arr[2] = p3;

        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
           Phone phone = arr[i] ;
           sum = sum + phone.getPrice();
        }
        double avg = sum/ arr.length;
        System.out.println(avg);
    }
}
